<template>
  <div>
    <detail-banner :imgs="imgs" :imgNumber="imgNumber" :imgUrl="imgUrl"></detail-banner>
    <detail-header></detail-header>
    <div class="content">
      <detail-list :list="list"></detail-list>
    </div>
  </div>
</template>
<script>
import DetailBanner from './components/Banner.vue'
import DetailHeader from './components/Header.vue'
import DetailList from './components/list.vue'
import axios from 'axios'
export default {
  name: 'Detail',
  components: {
    DetailBanner,
    DetailHeader,
    DetailList
  },
  data () {
    return {
      list: [],
      imgs: [],
      imgNumber: 0,
      imgUrl: ''
    }
  },
  mounted () {
    this.getDetailInfo()
  },
  methods: {
    getDetailInfo () {
      axios.get('/api/detail.json', {
        params: {
          id: this.$route.params.id
        }
      }).then(res => {
        res = res.data
        console.log(res)
        if (res.ret && res.data) {
          this.list = res.data.categoryList
          this.imgs = res.data.gallaryImgs
          this.imgNumber = this.imgs.length
          this.imgUrl = res.data.bannerImg
        }
      })
    }
  }
}
</script>
<style lang="stylus" type="text/stylus" scoped>
.content
  height 50rem
</style>
